package com.web.taglibs;

import javax.servlet.jsp.tagext.TagSupport;
import javax.servlet.jsp.JspException;
import java.io.IOException;

public class ShowTreeTag extends TagSupport {
	public int doEndTag() throws JspException {
		StringBuffer buffer = showTree();
		try {
			pageContext.getOut().println(buffer.toString());
		} catch (IOException ioe) {
			ioe.printStackTrace();
		}
		return super.doEndTag();
	}

	private StringBuffer showTree() {
		StringBuffer sb = new StringBuffer();
		sb.append("<div class=\"tree\">\n");
		sb.append("<script type=\"text/javascript\">\n");
		sb.append("<!--\n");
		sb.append("document.write(d);\n");
		sb.append("//-->\n");
		sb.append("</script>\n");
		sb.append("</div>\n");
		return sb;
	}
}
